#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=60;
int n,f[MAXN][MAXN][2];
char a[MAXN];
bool check(int l,int r)
{
	int len=r-l+1;
	if(len&1)return false;
	for(int i=l;i<=(l+r)>>1;++i)
		if(a[i]!=a[i+(len>>1)])return false;
	return true;
}
int dfs(int l,int r,bool k)
{
	if(l==r)return 1;
	int ret=r-l+1;
	if(f[l][r][k])return f[l][r][k];
	if(k)
		for(int i=l;i<r;++i)
			ret=min(ret,dfs(l,i,true)+dfs(i+1,r,true)+1);
	for(int i=l;i<r;++i)
		ret=min(ret,dfs(l,i,k)+r-i);
	if(check(l,r))
		ret=min(ret,dfs(l,(l+r)>>1,false)+1);
	return f[l][r][k]=ret;
}
int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	printf("%d\n",dfs(1,n,true));
	return 0;
}
